<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ include file="../../include/easyui.jsp" %>
<%@ include file="../../include/pForm.jsp" %>
<%@ include file="../../include/pGrid.jsp" %>
<%@ include file="/WEB-INF/jsp/include/easyui-layui-upload.jsp" %>
<style type="text/css">
	.textbox-label{width:110px;margin-left: 10px;}
</style>
<title>供应商资料</title>
<script type="text/javascript">
	$(function(){
		var unit = '${unit}' || {};
		unit = JSON.parse(unit);
		$("#easyuiForm").form("load",unit );
		$("#company").form("load",unit );
		$("#personal").form("load",unit );
		
		$("#toolbar .easyui-linkbutton").on("click", function() {
			var id = $(this).attr("motion_code");p.btnOneClick($(this));
			switch (id) {
				case "02":
					$('#easyuiForm').form('submit',{
						iframe:false,
						queryParams: {} ,
						onSubmit:function(param){
							return $(this).form('enableValidation').form('validate');
						},
						success:function(data){
							var json = JSON.parse(data);
							if(json && json.flag){
								$.messager.show({ title:'我的消息', msg: '提交成功！',timeout:3000, showType:'slide' });
							}else{
								alert(json.msg || '后台处理失败！');
							}
						}
					});
					break;
				default:
					break;
			}
		});
		
		var pFn = {
				frushForm:function(kind){
					if(kind==0){
						this.showCompany();
					}else{
						this.showPersonal();
					}
				},
				showCompany: function(){
					$("#company").insertAfter("#formTarget");
					$("#personal").appendTo("#temp");
				},
				showPersonal: function(){
					$("#personal").insertAfter("#formTarget");
					$("#company").appendTo("#temp");
				}
		};
		
		$('#sbutton').switchbutton({  
	        checked: false,  
	        onText:"公司",
	        offText:"个人",
	        onChange: function(checked){
	        	checked = checked || false;
	            if (checked){
	            	$("#unitKind").val("0");
	            	pFn.frushForm(0);
	            }else{
	            	$("#unitKind").val("1");
	            	pFn.frushForm(1);
	            } 
	            return;
	    	}  
        });
		
		$('#isSbutton').switchbutton({  
	        checked: true,  
	        onText:"是",
	        offText:"否",
	        onChange: function(checked){  
	            if (checked == true){
	            	$("#threeInOne").val("0");
	            	$("#no").hide();
	            	$("#yes").show();
	                return;  
	            }  
	            if (checked == false){  
	            	$("#threeInOne").val("1");
	            	$("#no").show();
	            	$("#yes").hide();
	            	return; 
	            }}  
        	});
		
		/*数据回显*/
		if(unit.unitKind && unit.unitKind==0){
			$('#sbutton').switchbutton('check');
			pFn.frushForm(0);
			$("#unitKind").val("0");
		}else{
			$('#sbutton').switchbutton('uncheck');
			pFn.frushForm(1);
			$("#unitKind").val("1");
		}
		
		if(unit.threeInOne && unit.threeInOne ==0){
			$('#isSbutton').switchbutton('check');
		}else{
			$('#isSbutton').switchbutton('uncheck');
		}
		
		$("#toolbar").width(120);
	});
</script>
</head>
 <body>
    <div class="easyui-panel" data-options="fit:true,border:false" style="margin: 10px;">
			<!-- 替换自动form表单 -->
			<form id="easyuiForm" method="post" action="/console/supplier/rewrite/modify">
			 <input type="hidden" name="createrId" value="${SESSION_USER.user.id}" />
			 <input type="hidden" name="id" value="" />
			 <input type="hidden" id="unitKind" name="unitKind" value="0">
			
			 <!--类名属性及默认主键id-->
			  <div class="tableRow">
			  		<input class="easyui-textbox" name="unitNo" style="width:270px;" data-options="label:'供应商编码:'" readonly="readonly" value=""/>
			 		<label class="textbox-label textbox-label-before" for="sbutton" style="text-align: left; height: 24px; line-height: 24px;">注册类型:</label>
					<input id="sbutton" style="width:60px;height:25px;">
			 </div>
			 
			  <div class="tableRow" style="margin-top: 10px;" id="formTarget">
			  		<input class="easyui-textbox" name="name" style="width:550px;" data-options="label:'供应商单位名称:'" value=""/>
			 </div>
			 <!-- 公司 -->
			 
			 <!-- 个人 -->
			 
			 <div class="tableRow" style="margin-top: 10px;">
			  	<input class="easyui-layuiupload" name="attachment" style="width:550px;" data-options="label:'上传附件:',upload:{auto:false,height:250} " />
			 </div>
			 
			 <!-- 提交按钮 -->
			 <div class="tableRow" style="margin-top: 20px;margin-left: 300px;margin-bottom: 50px;">
			 	<div id="toolbar" class="easyui-panel" style="padding:3px;" data-options="fit:false,border:false"></div>
			 </div>
			</form>
	</div>
	
<div id="temp" style="display: none;">
	<div id="company" >
			 	<div class="tableRow" style="margin-top: 10px;">
				  <input class="easyui-textbox" name="lealPerson" style="width:270px;" data-options="label:'法人代表:'" value=""/>
				  <input class="easyui-textbox" name="lealPersonCard" style="width:270px;" data-options="label:'法人身份证:'" value=""/>
				 </div>
			 	<div class="tableRow" style="margin-top: 10px;">
				  <input class="easyui-datebox" name="lealPersonCardEndDate" style="width:270px;" data-options="label:'身份证截至日期:'" value=""/>
				  <input class="easyui-textbox" name="businessType" style="width:270px;" data-options="label:'公司经营性质:'" value=""/>
				 </div>
			 	<div class="tableRow" style="margin-top: 10px;">
				  <input class="easyui-numberbox" name="registeredCapital" style="width:270px;" data-options="label:'注册资金:'" value=""/>
				  <input class="easyui-datebox" name="registeredDate" style="width:270px;" data-options="label:'注册时间:'" value=""/>
				 </div>
				 <div class="tableRow" style="margin-top: 10px;">
				  <input class="easyui-textbox" name="businessScope" style="width:270px;" data-options="label:'营业范围:'" value=""/>
				  <input class="easyui-textbox" name="registeredAddr" style="width:270px;" data-options="label:'注册地址:'" value=""/>
				 </div>
				 <div class="tableRow" style="margin-top: 10px;">
				  <input class="easyui-textbox" name="linkAddr" style="width:270px;" data-options="label:'通讯地址:'" value=""/>
				  <input class="easyui-textbox" name="taxProperty" style="width:270px;" data-options="label:'企业纳税性质:'" value=""/>
				 </div>
				 <div class="tableRow" style="margin-top: 10px;">
				  <input type="hidden" id="threeInOne" name="threeInOne" value="0">
				  <label class="textbox-label textbox-label-before" for="isSbutton" style="text-align: left; height: 24px; line-height: 24px;">三证合一:</label>
				 	<input id="isSbutton" style="width:60px;height:25px;">
				 </div>
				 <div id="yes" >
				 	<div class="tableRow" style="margin-top: 10px;">
					  <input class="easyui-textbox" name="unifiedCreditCode" style="width:550px;" data-options="label:'统一社会信用代码:'" value=""/>
					 </div>
				 </div>
				 <div id="no" style="display: none;">
				 	<div class="tableRow" style="margin-top: 10px;">
					  <input class="easyui-textbox" name="licenseNumber" style="width:550px;" data-options="label:'营业执照注册号:'" value=""/>
					 </div>
					 <div class="tableRow" style="margin-top: 10px;">
					 	<input class="easyui-textbox" name="organizationNo" style="width:270px;" data-options="label:'组织机构代码:'" value=""/>
					  	<input class="easyui-textbox" name="taxId" style="width:270px;" data-options="label:'税务登记号:'" value=""/>
					 </div>
				 </div>
				 <div class="tableRow" style="margin-top: 10px;">
				  <input class="easyui-textbox" name="bank" style="width:270px;" data-options="label:'开户银行:'" value=""/>
				  <input class="easyui-textbox" name="accountPayee" style="width:270px;" data-options="label:'银行账户:'" value=""/>
				 </div>
				 <div class="tableRow" style="margin-top: 10px;margin-bottom: 10px;">
				  <input class="easyui-textbox" name="remark" style="width:550px;height:50px;" data-options="label:'公司简介:',validType:'length[0,500]',multiline:true"  value=""/>
				 </div>
			 </div>
	
		<div id="personal"  >
			 	<div class="tableRow" style="margin-top: 10px;">
				  	<input class="easyui-textbox" name="lealPersonCard" style="width:270px;" data-options="label:'身份证号码:'" value=""/>
				  	<input class="easyui-datebox" name="lealPersonCardEndDate" style="width:270px;" data-options="label:'身份证截至日期:'" value=""/>
				 </div>
				 <div class="tableRow" style="margin-top: 10px;">
				  	<input class="easyui-textbox" name="bank" style="width:270px;" data-options="label:'开户银行:'" value=""/>
				  	<input class="easyui-textbox" name="accountPayee" style="width:270px;" data-options="label:'银行账户:'" value=""/>
				 </div>
				 <div class="tableRow" style="margin-top: 10px;">
				  	<input class="easyui-textbox" name="linkAddr" style="width:540px;" data-options="label:'通讯地址:'" value=""/>
				 </div>
				 <div class="tableRow" style="margin-top: 10px;margin-bottom: 10px;">
				  <input class="easyui-textbox" name="businessScope" style="width:540px;height: 50px;" multiline="true" value=""   data-options="label:'业务范围:',validType:'length[0,500]'"  />
				 </div>
			 </div>
		</div>
  </body>
</html>
